package com.zhentao.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhentao.pojo.Department;
import com.zhentao.pojo.Doctor;
import com.zhentao.pojo.MedicalRecord;
import com.zhentao.pojo.Patient;
import com.zhentao.service.MedicalRecordService;
import com.zhentao.service.PatientService;
import com.zhentao.vo.QueryParam;
import com.zhentao.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("patients")
public class PatientController {
    @Autowired
    private PatientService patientService;
    @Autowired
    private MedicalRecordService medicalRecordService;


    @RequestMapping("findPage")
    public Result findPage(@RequestBody QueryParam queryParam){
        Page<Patient> page = patientService.findPage(queryParam);
        return Result.OK(page);
    }

//    查找部门
    @RequestMapping("findDepartment")
    public Result findDepartment(Integer patientId){
        List<Department> department = patientService.findDepartment(patientId);
        return Result.OK(department);
    }

//    查找病历
// 修改后的Controller方法
@RequestMapping("findMedicalRecordByPatient")
public Result findMedicalRecordByPatient(Integer patientId) {
    MedicalRecord record = medicalRecordService.findMedicalRecord(patientId);
    return Result.OK(record);
}

//    查询患者
    @RequestMapping("findPatientById")
    public Result findPatientById(Integer patientId){
        Patient patient = patientService.findPatientById(patientId);
        return Result.OK(patient);
    }

//    查询主治医生
    @RequestMapping("findDoc")
    public Result findDoc(Integer patientId){
        List<Doctor> doctorList = patientService.findDoc(patientId);
        System.err.println(doctorList);
        return Result.OK(doctorList);
    }
}
